/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

/*
 * RelatoriosGUI.java
 *
 * Created on 06/03/2010, 11:25:09
 */
package gui;

import facade.AdvogadoFacade;
import java.awt.Component;
import javax.swing.JPanel;
import javax.swing.JToolBar;

/**
 *
 * @author andrehadm
 */
public class RelatoriosGUI extends javax.swing.JPanel {

    JPanel areaDeTrabalho;
    JToolBar barraDeFerramentas;
    AdvogadoFacade advogadoFacade;

    /** Creates new form RelatoriosGUI */
    public RelatoriosGUI(JPanel areaDeTrabalho, JToolBar barra, AdvogadoFacade advogadoFacade) {
        this.areaDeTrabalho = areaDeTrabalho;
        this.barraDeFerramentas = barra;
        this.advogadoFacade = advogadoFacade;
        initComponents();
    }

    private void habilitaBotoesBarraDeFerramentas() {
        for (Component botoes : barraDeFerramentas.getComponents()) {
            botoes.setEnabled(true);
        }
        System.out.println("");
        System.out.println("Todos os botoes habilitados.");
    }

    /** This method is called from within the constructor to
     * initialize the form.
     * WARNING: Do NOT modify this code. The content of this method is
     * always regenerated by the Form Editor.
     */
    @SuppressWarnings("unchecked")
    // <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents
    private void initComponents() {

        jPanelArea = new javax.swing.JPanel();
        jButton_Carregar = new javax.swing.JButton();
        jButton_Sair = new javax.swing.JButton();
        jComboBox_Relatorios = new javax.swing.JComboBox();

        setBorder(javax.swing.BorderFactory.createTitledBorder("Relatorios"));

        javax.swing.GroupLayout jPanelAreaLayout = new javax.swing.GroupLayout(jPanelArea);
        jPanelArea.setLayout(jPanelAreaLayout);
        jPanelAreaLayout.setHorizontalGroup(
            jPanelAreaLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGap(0, 388, Short.MAX_VALUE)
        );
        jPanelAreaLayout.setVerticalGroup(
            jPanelAreaLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGap(0, 228, Short.MAX_VALUE)
        );

        jButton_Carregar.setText("Carregar");
        jButton_Carregar.addMouseListener(new java.awt.event.MouseAdapter() {
            public void mouseClicked(java.awt.event.MouseEvent evt) {
                jButton_CarregarMouseClicked(evt);
            }
        });

        jButton_Sair.setText("Sair");
        jButton_Sair.addMouseListener(new java.awt.event.MouseAdapter() {
            public void mouseClicked(java.awt.event.MouseEvent evt) {
                jButton_SairMouseClicked(evt);
            }
        });

        jComboBox_Relatorios.setModel(new javax.swing.DefaultComboBoxModel(new String[] { "Clientes", "Clientes Por Cidade", "Processos", "Processos Por Cliente", "Processos Por Comarca" }));

        javax.swing.GroupLayout layout = new javax.swing.GroupLayout(this);
        this.setLayout(layout);
        layout.setHorizontalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addComponent(jPanelArea, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
            .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, layout.createSequentialGroup()
                .addComponent(jComboBox_Relatorios, 0, 267, Short.MAX_VALUE)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addComponent(jButton_Carregar)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addComponent(jButton_Sair)
                .addContainerGap())
        );
        layout.setVerticalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(layout.createSequentialGroup()
                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(jButton_Sair)
                    .addComponent(jComboBox_Relatorios, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(jButton_Carregar))
                .addGap(18, 18, 18)
                .addComponent(jPanelArea, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
        );
    }// </editor-fold>//GEN-END:initComponents

    private void jButton_SairMouseClicked(java.awt.event.MouseEvent evt) {//GEN-FIRST:event_jButton_SairMouseClicked
        habilitaBotoesBarraDeFerramentas();
        areaDeTrabalho.removeAll();
        areaDeTrabalho.revalidate();
        areaDeTrabalho.repaint();
    }//GEN-LAST:event_jButton_SairMouseClicked

    private void jButton_CarregarMouseClicked(java.awt.event.MouseEvent evt) {//GEN-FIRST:event_jButton_CarregarMouseClicked
        jPanelArea.removeAll();
        if(jComboBox_Relatorios.getSelectedItem().equals("Clientes")){
            ClienteRelatorioGUI clienteRelatorio = new ClienteRelatorioGUI( advogadoFacade);
            clienteRelatorio.setSize(jPanelArea.getWidth() - 15, jPanelArea.getHeight() - 15 );
            //jPanelArea.removeAll();
            jPanelArea.add(clienteRelatorio);    
            //jPanelArea.revalidate();
            System.out.println("");
            System.out.println("Cliente Relatorio.");
        } else if(jComboBox_Relatorios.getSelectedItem().equals("Clientes Por Cidade")){
            ClienteRelatorioCidadeGUI clienteRelatorioCidade = new ClienteRelatorioCidadeGUI( advogadoFacade);
            clienteRelatorioCidade.setSize(jPanelArea.getWidth() - 15, jPanelArea.getHeight() - 15 );
            jPanelArea.add(clienteRelatorioCidade);
            System.out.println("");
            System.out.println("Cliente Relatorio Cidade.");
        } else if(jComboBox_Relatorios.getSelectedItem().equals("Processos")){
            ProcessoRelatorioGUI processoRelatorio = new ProcessoRelatorioGUI( advogadoFacade);
            processoRelatorio.setSize(jPanelArea.getWidth() - 15, jPanelArea.getHeight() - 15 );
            jPanelArea.add(processoRelatorio);
            System.out.println("");
            System.out.println("Processo Relatorio.");
        } else if(jComboBox_Relatorios.getSelectedItem().equals("Processos Por Cliente")){
            ProcessoRelatorioClienteGUI processoRelatorioCliente = new ProcessoRelatorioClienteGUI( advogadoFacade);
            processoRelatorioCliente.setSize(jPanelArea.getWidth() - 15, jPanelArea.getHeight() - 15 );
            jPanelArea.add(processoRelatorioCliente);
            System.out.println("");
            System.out.println("Processo Relatorio Por Cliente.");
        } else if(jComboBox_Relatorios.getSelectedItem().equals("Processos Por Comarca")){
            ProcessoRelatorioComarcaGUI processoRelatorioComarca = new ProcessoRelatorioComarcaGUI( advogadoFacade);
            processoRelatorioComarca.setSize(jPanelArea.getWidth() - 15, jPanelArea.getHeight() - 15 );
            jPanelArea.add(processoRelatorioComarca);
            System.out.println("");
            System.out.println("Processo Relatorio Por Comarca.");
        }
        jPanelArea.revalidate();
    }//GEN-LAST:event_jButton_CarregarMouseClicked

    // Variables declaration - do not modify//GEN-BEGIN:variables
    private javax.swing.JButton jButton_Carregar;
    private javax.swing.JButton jButton_Sair;
    private javax.swing.JComboBox jComboBox_Relatorios;
    private javax.swing.JPanel jPanelArea;
    // End of variables declaration//GEN-END:variables
}
